package top.frsf.object.zombie;

import lombok.extern.slf4j.Slf4j;
import top.frsf.constants.ImageConstant;

import javax.imageio.ImageIO;
import java.awt.*;
import java.io.File;
import java.io.IOException;

/**
 * 普通zom
 *
 * @author FRSF
 * @since 2025/8/3 13:19
 */
@Slf4j
public class NormalZom extends ZomObject {
    /**
     * 移动图片
     */
    private static final Image[] move = new Image[21];
    /**
     * 减速移动图片
     */
    private static final Image[] snowMove = new Image[21];
    /**
     * 攻击图片
     */
    private static final Image[] attack = new Image[21];

    static {
        try {
            for (int i = 0; i < 21; i++) {
                String moveUrl = String.format(ImageConstant.Zom.ZOM_MOVE, i);
                move[i] = ImageIO.read(new File(moveUrl));
                String snowMoveUrl = String.format(ImageConstant.Zom.ZOM_SNOW_MOVE, i);
                snowMove[i] = ImageIO.read(new File(snowMoveUrl));
                String attackUrl = String.format(ImageConstant.Zom.ZOM_ATTACK, i);
                attack[i] = ImageIO.read(new File(attackUrl));
            }
        } catch (IOException e) {
            log.error("图片加载失败", e);
            throw new RuntimeException(e);
        }
    }

    public NormalZom(String img, int x, int y, int width, int height) {
        super(img, x, y, width, height, 100, 5, 10);
        addAnimation(ImageConstant.Zom.ZOM_MOVE, move);
        addAnimation(ImageConstant.Zom.ZOM_SNOW_MOVE, snowMove);
        addAnimation(ImageConstant.Zom.ZOM_ATTACK, attack);
        switchAnimation(ImageConstant.Zom.ZOM_MOVE, 80, true);
        setMoveCd(500);
    }

}
